﻿using System;
using Microsoft.EntityFrameworkCore.Metadata;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace WhutDoomCheck.Server.Migrations
{
    public partial class Add_Record : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "Records",
                columns: table => new
                {
                    Id = table.Column<int>(type: "int", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
                    Sno = table.Column<string>(type: "varchar(255)", nullable: false)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    OldDoomId = table.Column<int>(type: "int", nullable: true),
                    NewDoomId = table.Column<int>(type: "int", nullable: true),
                    OldAddress = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    NewAddress = table.Column<string>(type: "longtext", nullable: true)
                        .Annotation("MySql:CharSet", "utf8mb4"),
                    CreateTime = table.Column<DateTime>(type: "datetime(6)", nullable: false)
                        .Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.ComputedColumn),
                    Status = table.Column<int>(type: "int", nullable: false)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_Records", x => x.Id);
                    table.ForeignKey(
                        name: "FK_Records_Dooms_NewDoomId",
                        column: x => x.NewDoomId,
                        principalTable: "Dooms",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_Records_Dooms_OldDoomId",
                        column: x => x.OldDoomId,
                        principalTable: "Dooms",
                        principalColumn: "Id");
                    table.ForeignKey(
                        name: "FK_Records_Students_Sno",
                        column: x => x.Sno,
                        principalTable: "Students",
                        principalColumn: "Sno",
                        onDelete: ReferentialAction.Cascade);
                })
                .Annotation("MySql:CharSet", "utf8mb4");

            migrationBuilder.CreateIndex(
                name: "IX_Records_NewDoomId",
                table: "Records",
                column: "NewDoomId");

            migrationBuilder.CreateIndex(
                name: "IX_Records_OldDoomId",
                table: "Records",
                column: "OldDoomId");

            migrationBuilder.CreateIndex(
                name: "IX_Records_Sno",
                table: "Records",
                column: "Sno");
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "Records");
        }
    }
}
